package com.example.todolist.service;

import com.example.todolist.entity.Mail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

@Configuration
public class MailService {
    @Autowired
    private JavaMailSender mailSender;
    public void sendMailMessage(Mail mail)
    {
        System.out.println(mail);
        SimpleMailMessage simpleMailMessage=new SimpleMailMessage();
        simpleMailMessage.setFrom(mail.getFrom());
        simpleMailMessage.setTo(mail.getTo());
        simpleMailMessage.setText(mail.getContent());
        simpleMailMessage.setSubject("TomatoDo");
        mailSender.send(simpleMailMessage);
    }
    public Mail getRemindMessage(String taskName,String email,String name)
    {
        return new Mail("尊敬的"+name+",您制定的"+taskName+"学习任务，为了获取最佳的复习效果，我们推荐您今天进行及时复习，",email,"TomatoDo");
    }

    public Mail getTaskMessage(String taskName,String email,String name)
    {
        return new Mail("尊敬的"+name+",您的"+taskName+"任务明天就要截止了！",email,"TomatoDO");
    }
}
